﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace _2011DBProject
{
    public partial class Caddie : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["USER"] == null || Session["SERVER"] == null || Session["Ch"] == null || Session["CHARACTER_NAME"] == null)
            {
                Response.Redirect("default.aspx?isNoSession=1");
            }
        }

        protected void btnApplyToCharacter_Click(object sender, EventArgs e)
        {
            try
            {
                if (lblItem.Text == "선택된 아이템이 없습니다.") return;
                DataSet1TableAdapters.MY_ITEMTableAdapter taMyItem = new _2011DBProject.DataSet1TableAdapters.MY_ITEMTableAdapter();
                taMyItem.Connection.ConnectionString = Settings.strConnectionString;
                DataSet1.MY_ITEMDataTable dtMyItem = taMyItem.GetDataByServerNoCharacterNameItemNoUniqItemNo(Settings.decServer, Settings.strCharacterName, Convert.ToDecimal(lblItem.Text), Convert.ToDecimal(lblUnique.Text));
                if (dtMyItem.Count > 0)
                {
                    DataSet1.MY_ITEMRow row = dtMyItem[0];
                    row.CADDIE_EQUIP = "N";
                    taMyItem.Update(dtMyItem);
                    sqldsMyItem.DataBind();
                    dvMyItem.DataBind();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                lblItem.Text = "선택된 아이템이 없습니다.";
                lblUnique.Text = "Label";
            }
        }

        protected void dvMyItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                lblItem.Text = dvMyItem.DataKeys[dvMyItem.SelectedIndex].Values[0].ToString();
                lblUnique.Text = dvMyItem.DataKeys[dvMyItem.SelectedIndex].Values[1].ToString();
            }
            catch (Exception)
            {
                throw;
            }
        }
        protected void btnGoLogout_onclick(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect("Default.aspx");
        }
        protected void btnGoServer_onclick(object sender, EventArgs e)
        {
            Response.Redirect("Server.aspx");
        }
        protected void btnGoCharacter_onclick(object sender, EventArgs e)
        {
            Response.Redirect("Character.aspx");
        }
        protected void btnGoChannel_onclick(object sender, EventArgs e)
        {
            Response.Redirect("Channel.aspx");
        }
        protected void btnGoMain_onclick(object sender, EventArgs e)
        {
            Response.Redirect("Gameroom.aspx");
        }
    }
}
